<template>
  <el-dialog :center = "false" :close-on-click-modal = "false" :close-on-press-escape = "false" :lock-scroll = "true"
             :title = "batchDialogTitle"
             top = "20px" v-model = "batchDialogTableVisible" width = "80%">
    <el-row class = "batch_row_btn">
      <el-button @click = "handleAddDetails" link size = "mini" type = "primary">
        <user-icon icon = "plus-circle" style = "color:#e3e9f2;"/>
        添加
      </el-button>
      <el-button @click = "handleDeleteDetails" size = "mini" type = "success">
        <user-icon icon = "trash" style = "color:#e3e9f2;"/>
        删除
      </el-button>
      <el-button @click = "handleDeleteAllDetails" link size = "mini" type = "danger">
        <user-icon icon = "trash-alt" style = "color:#e3e9f2;"/>
        清空
      </el-button>
    </el-row>
    <el-table
        :data = "ruleForm.batchDataList"
        :row-class-name = "rowClassName"
        @selection-change = "handleDetailSelectionChange"
        border
        fit = "true"
        ref = "tb"
        v-loading = "loading"
    >
      <el-table-column align = "center" type = "selection" width = "30"/>
      <el-table-column align = "center" label = "序号" prop = "xh" width = "50"></el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "主键"
          min-width = "200px"
          prop = "idFeedback"
          required
          sortable v-if = " false ">
        <template #default = "scope">
          <el-input-number clearable placeholder = "请输入主键"
                           v-model = "batchDataList[scope.row.xh-1].idFeedback"/>
        </template>
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "反馈标题"
          min-width = "200px"
          prop = "feedbackTitle"
          required
          sortable v-if = "true ">
        <template #default = "scope">
          <el-input clearable placeholder = "请输入反馈标题"
                    v-model = "batchDataList[scope.row.xh-1].feedbackTitle"></el-input>
        </template>
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "反馈内容"
          min-width = "200px"
          prop = "feedbackContent"
          required
          sortable v-if = "true ">
        <template #default = "scope">
          <el-input clearable placeholder = "请输入反馈内容"
                    v-model = "batchDataList[scope.row.xh-1].feedbackContent"></el-input>
        </template>
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "修改人"
          min-width = "200px"
          prop = "updatedBy"
          sortable
          v-if = " false ">
        <template #default = "scope">
          <el-input clearable placeholder = "请输入修改人"
                    v-model = "batchDataList[scope.row.xh-1].updatedBy"></el-input>
        </template>
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "修改时间"
          min-width = "200px"
          prop = "updatedDate"
          sortable
          v-if = " false ">
        <template #default = "scope">
          <el-date-picker clearable placeholder = "请选择修改时间"
                          type = "date"
                          v-model = "batchDataList[scope.row.xh-1].updatedDate">
          </el-date-picker>
        </template>
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "创建人"
          min-width = "200px"
          prop = "createdBy"
          sortable
          v-if = " false ">
        <template #default = "scope">
          <el-input clearable placeholder = "请输入创建人"
                    v-model = "batchDataList[scope.row.xh-1].createdBy"></el-input>
        </template>
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "创建时间"
          min-width = "200px"
          prop = "createdDate"
          sortable
          v-if = " false ">
        <template #default = "scope">
          <el-date-picker clearable placeholder = "请选择创建时间"
                          type = "date"
                          v-model = "batchDataList[scope.row.xh-1].createdDate">
          </el-date-picker>
        </template>
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "是否删除 0 否 1 是"
          min-width = "200px"
          prop = "isDel"
          sortable
          v-if = " false ">
        <template #default = "scope">
          <el-input-number clearable placeholder = "请输入是否删除 0 否 1 是"
                           v-model = "batchDataList[scope.row.xh-1].isDel"/>
        </template>
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "状态码名称"
          min-width = "200px"
          prop = "statusName"
          required
          sortable v-if = "true ">
        <template #default = "scope">
          <el-input clearable placeholder = "请输入状态码名称"
                    v-model = "batchDataList[scope.row.xh-1].statusName"></el-input>
        </template>
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "状态码"
          min-width = "200px"
          prop = "statusCode"
          sortable
          v-if = " false ">
        <template #default = "scope">
          <el-input clearable placeholder = "请输入状态码"
                    v-model = "batchDataList[scope.row.xh-1].statusCode"></el-input>
        </template>
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "业务关联字段"
          min-width = "200px"
          prop = "foreignId"
          required
          sortable v-if = "true ">
        <template #default = "scope">
          <el-input-number clearable placeholder = "请输入业务关联字段"
                           v-model = "batchDataList[scope.row.xh-1].foreignId"/>
        </template>
      </el-table-column>
    </el-table>
    <el-row class = "batch_submit_btn">
      <el-button @click = "batchMerge()" link type = "primary">
        <user-icon icon = "save"/>
        <span style = "vertical-align: middle;">  提交 </span>
      </el-button>
      <el-button @click = "batchMergeDraft()" link type = "primary">
        <user-icon icon = "save"/>
        <span style = "vertical-align: middle;">  暂存 </span>
      </el-button>
      <el-button @click = "resetForm()" link>
        <user-icon icon = "undo"/>
        <span style = "vertical-align: middle;">  重置 </span>
      </el-button>
    </el-row>
  </el-dialog>

  <el-dialog :center = "false" :close-on-click-modal = "false" :close-on-press-escape = "false" :lock-scroll = "true"
             :title = "dialogTitle"
             top = "20px" v-model = "dialogTableVisible" width = "80%">

    <el-form :model = "ruleForm" :rules = "rules" class = "demo-ruleForm" ref = "ruleForm">
      <el-form-item label = "主键" prop = "idFeedback" v-if = "false">
        <el-input clearable placeholder = "请输入主键"
                  v-model = "ruleForm.idFeedback"></el-input>
      </el-form-item>

      <el-form-item label = "反馈标题" prop = "feedbackTitle"
                    required v-if = "!false">
        <el-input clearable placeholder = "请输入反馈标题"
                  v-model = "ruleForm.feedbackTitle"></el-input>
      </el-form-item>

      <el-form-item label = "反馈内容" prop = "feedbackContent"
                    required v-if = "!false">
        <el-input clearable placeholder = "请输入反馈内容"
                  v-model = "ruleForm.feedbackContent"></el-input>
      </el-form-item>

      <el-form-item label = "修改人" prop = "updatedBy"
                    v-if = "!true">
        <el-input clearable placeholder = "请输入修改人"
                  v-model = "ruleForm.updatedBy"></el-input>
      </el-form-item>

      <el-form-item label = "修改时间" prop = "updatedDate"
                    v-if = "!true">
        <el-date-picker clearable placeholder = "请选择修改时间" type = "date"
                        v-model = "ruleForm.updatedDate">
        </el-date-picker>
      </el-form-item>

      <el-form-item label = "创建人" prop = "createdBy"
                    v-if = "!true">
        <el-input clearable placeholder = "请输入创建人"
                  v-model = "ruleForm.createdBy"></el-input>
      </el-form-item>

      <el-form-item label = "创建时间" prop = "createdDate"
                    v-if = "!true">
        <el-date-picker clearable placeholder = "请选择创建时间" type = "date"
                        v-model = "ruleForm.createdDate">
        </el-date-picker>
      </el-form-item>

      <el-form-item label = "是否删除 0 否 1 是" prop = "isDel"
                    v-if = "!true">
        <el-input-number clearable placeholder = "请输入是否删除 0 否 1 是"
                         v-model = "ruleForm.isDel"/>
      </el-form-item>

      <el-form-item label = "状态码名称" prop = "statusName"
                    required v-if = "!false">
        <el-input clearable placeholder = "请输入状态码名称"
                  v-model = "ruleForm.statusName"></el-input>
      </el-form-item>

      <el-form-item label = "状态码" prop = "statusCode"
                    v-if = "!true">
        <el-select placeholder = "请选择状态码" v-model = "ruleForm.statusCode">
          <el-option
              :key = "sitem.value"
              :label = "sitem.name"
              :value = "sitem.value"
              clearable
              v-for = "sitem in selectData"
          >
          </el-option>
        </el-select>
      </el-form-item>

      <el-form-item label = "业务关联字段" prop = "foreignId"
                    required v-if = "!false">
        <el-input-number clearable placeholder = "请输入业务关联字段"
                         v-model = "ruleForm.foreignId"/>
      </el-form-item>

      <el-form-item>
        <el-button @click = "merge()" link type = "primary">
          <user-icon icon = "save"/>
          <span style = "vertical-align: middle;">  提交 </span>
        </el-button>
        <el-button @click = "mergeDraft()" link type = "primary">
          <user-icon icon = "save"/>
          <span style = "vertical-align: middle;">  暂存 </span>
        </el-button>
        <el-button @click = "resetForm()" link>
          <user-icon icon = "undo"/>
          <span style = "vertical-align: middle;">  重置 </span>
        </el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
  <el-dialog :center = "false" :close-on-click-modal = "false" :close-on-press-escape = "false" :lock-scroll = "true"
             title = "查看数据"
             top = "20px" v-model = "viewVisible" width = "80%">
    <el-form :model = "ruleForm" class = "view-ruleForm" label-width = "15%" ref = "ruleForm">
      <el-form-item label = "主键" prop = "idFeedback">
        <span>{{ ruleForm.idFeedback }}</span>
      </el-form-item>
      <el-form-item label = "反馈标题" prop = "feedbackTitle">
        <span>{{ ruleForm.feedbackTitle }}</span>
      </el-form-item>
      <el-form-item label = "反馈内容" prop = "feedbackContent">
        <span>{{ ruleForm.feedbackContent }}</span>
      </el-form-item>
      <el-form-item label = "修改人" prop = "updatedBy">
        <span>{{ ruleForm.updatedBy }}</span>
      </el-form-item>
      <el-form-item label = "修改时间" prop = "updatedDate">
        <span>{{ ruleForm.updatedDate }}</span>
      </el-form-item>
      <el-form-item label = "创建人" prop = "createdBy">
        <span>{{ ruleForm.createdBy }}</span>
      </el-form-item>
      <el-form-item label = "创建时间" prop = "createdDate">
        <span>{{ ruleForm.createdDate }}</span>
      </el-form-item>
      <el-form-item label = "是否删除 0 否 1 是" prop = "isDel">
        <span>{{ ruleForm.isDel }}</span>
      </el-form-item>
      <el-form-item label = "状态码名称" prop = "statusName">
        <span>{{ ruleForm.statusName }}</span>
      </el-form-item>
      <el-form-item label = "状态码" prop = "statusCode">
        <span>{{ ruleForm.statusCode }}</span>
      </el-form-item>
      <el-form-item label = "业务关联字段" prop = "foreignId">
        <span>{{ ruleForm.foreignId }}</span>
      </el-form-item>
      <el-form-item>
        <el-button @click = "this.viewVisible=!this.viewVisible" type = "warning">关闭</el-button>
      </el-form-item>
    </el-form>
  </el-dialog>
  <div style = "height: 100%">
    <!--查询区域-->
    <table class = "inner_button">
      <tr>
        <td v-if = "permission.add">
          <el-button @click = "btnOperation(1)" link type = "primary">
            <user-icon icon = "plus"/>
            <span style = "vertical-align: middle;"> 新增 </span>
          </el-button>
        </td>
        <td v-if = "permission.batchAdd">
          <el-button @click = "btnOperation(11)" link type = "primary">
            <user-icon icon = "plus-square"/>
            <span style = "vertical-align: middle;"> 批量新增 </span>
          </el-button>
        </td>
        <td v-if = "permission.edit">
          <el-button @click = "btnOperation(2)" link type = "primary">
            <user-icon icon = "edit"/>
            <span style = "vertical-align: middle;">  编辑 </span>
          </el-button>
        </td>
        <td v-if = "permission.view">
          <el-button @click = "btnOperation(3)" link type = "primary">
            <user-icon icon = "book-open"/>
            <span style = "vertical-align: middle;">  查看 </span>
          </el-button>
        </td>
        <td v-if = "permission.delete">
          <el-button @click = "btnOperation(4)" link type = "danger">
            <user-icon icon = "minus-square"/>
            <span style = "vertical-align: middle;">  删除 </span>
          </el-button>
        </td>
        <td v-if = "permission.view">
          <el-button @click = "btnOperation(5)" link type = "primary">
            <user-icon icon = "sync"/>
            <span style = "vertical-align: middle;">  刷新 </span>
          </el-button>
        </td>
        <td v-if = "permission.download">
          <el-button @click = "btnOperation(6)" link type = "primary">
            <user-icon icon = "file-download"/>
            <span style = "vertical-align: middle;">  下载模板 </span>
          </el-button>
        </td>
        <td v-if = "permission.execution">
          <el-button @click = "btnOperation(7)" link type = "primary">
            <user-icon icon = "play-circle"/>
            <span style = "vertical-align: middle;">  执行 </span>
          </el-button>
        </td>
        <td v-if = "permission.upload">
          <el-upload
              :auto-upload = "true"
              :on-change = "upload"
              :on-error = "uploadError"
              :on-progress = "uploadProcess"
              :on-success = "uploadSuccess"
              :show-file-list = "false"
              action = "/lee-cms/cms/feedbackEntity/importData"
              class = "upload-demo"
              name = "file"
          >
            <el-button link type = "primary">
              <user-icon icon = "file-upload"/>
              <span style = "vertical-align: middle;">  上传 </span>
            </el-button>
          </el-upload>
        </td>
        <td v-if = "permission.export">
          <el-button @click = "btnOperation(8)" link type = "primary">
            <user-icon icon = "file-export"/>
            <span style = "vertical-align: middle;">  导出 </span>
          </el-button>
        </td>
      </tr>
    </table>

    <el-table
        :data = "dataList"
        :row-key = "getRowIdentity"
        @row-dblclick = "editData"
        @selection-change = "handleSelectionChange"
        border
        fit = "true"
        highlight-current-row = "true"
        id = "feedbackPo"
        max-height = "470px"
        ref = "multipleTable"
        stripe = "true"
        style = "width: 100%;height:81%">
      <el-table-column fixed width = "1"/>
      <el-table-column
          :reserve-selection = "true"
          align = "center"
          type = "selection"
      />
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "主键"
          min-width = "200px"
          prop = "idFeedback"
          sortable
          v-if = " false ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "反馈标题"
          min-width = "200px"
          prop = "feedbackTitle"
          sortable
          v-if = "true ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "反馈内容"
          min-width = "200px"
          prop = "feedbackContent"
          sortable
          v-if = "true ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "修改人"
          min-width = "200px"
          prop = "updatedBy"
          sortable
          v-if = " false ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "修改时间"
          min-width = "200px"
          prop = "updatedDate"
          sortable
          v-if = " false ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "创建人"
          min-width = "200px"
          prop = "createdBy"
          sortable
          v-if = " false ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "创建时间"
          min-width = "200px"
          prop = "createdDate"
          sortable
          v-if = " false ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "是否删除 0 否 1 是"
          min-width = "200px"
          prop = "isDel"
          sortable
          v-if = " false ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "状态码名称"
          min-width = "200px"
          prop = "statusName"
          sortable
          v-if = "true ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "状态码"
          min-width = "200px"
          prop = "statusCode"
          sortable
          v-if = " false ">
      </el-table-column>
      <el-table-column
          :formatter = "dataFormat"
          :show-overflow-tooltip = "true"
          label = "业务关联字段"
          min-width = "200px"
          prop = "foreignId"
          sortable
          v-if = "true ">
      </el-table-column>
    </el-table>
    <el-pagination
        :total = "totalData"
        @current-change = "pageChangeClick"
        @size-change = "pageSizeClick"
        layout = "total, sizes, prev, pager, next, jumper"
        v-model:currentPage = "currentPage"
        v-model:page-size = "pageSize"
        v-model:pageCount = "totalPage"/>
  </div>
</template>
<style>
</style>
<script>
import axios from "axios";
import {ElLoading} from "element-plus"
import {confirm, error, success, warning} from "../../utils/message";
import {download, permissionResources} from "../../api/star_horse";

export default {
  name: "FeedbackEntity",
  setup() {
    return {}
  },
  data() {
    return {
      loading: null,
      batchDialogTitle: "",
      batchDialogTableVisible: false,
      dialogTableVisible: false,
      uploadVisible: false,
      viewVisible: false,
      dialogTitle: "",
      ruleForm: {},
      dataList: [],
      permission: {view: "view"},
      checkedDetail: [],
      batchDataList: [],
      selectData: [],
      currentPage: 1,
      pageSize: 20,
      totalPage: 0,
      totalData: 0,
      rules: {}
    }
  },
  methods: {
    rowClassName({row, rowIndex}) {
      row.xh = rowIndex + 1;
    },
    //单选框选中数据
    handleDetailSelectionChange(selection) {
      if (selection.length > 1) {
        this.$refs.tb.clearSelection();
        this.$refs.tb.toggleRowSelection(selection.pop());
      } else {
        this.checkedDetail = selection;
      }
    },
    handleAddDetails() {
      if (this.batchDataList == undefined) {
        this.batchDataList = new Array();
      }
      let obj = {};
      obj.idFeedback = "";
      obj.feedbackTitle = "";
      obj.feedbackContent = "";
      obj.updatedBy = "";
      obj.updatedDate = "";
      obj.createdBy = "";
      obj.createdDate = "";
      obj.isDel = "";
      obj.statusName = "";
      obj.statusCode = "";
      obj.foreignId = "";
      this.batchDataList.push(obj);
    },
    handleDeleteDetails() {
      if (this.checkedDetail.length == 0) {
        warning("请先选择要删除的数据");
      } else {
        this.batchDataList.splice(this.checkedDetail[0].xh - 1, 1);
      }
    },
    handleDeleteAllDetails() {
      this.batchDataList = [];
    },
    dataFormat(row, column, cellValue, index) {
      if (!cellValue) {
        return "-";
      }
      if (column.property == "createdDate" || column.property == "updatedDate") {
        let date = new Date(cellValue);
        return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate();
      } else {
        return cellValue;
      }
    },
    /**
     * 加载框
     */
    load(msg) {
      if (!this.loading) {
        this.loading = ElLoading.service({
          lock: true,
          target: "#feedbackPo",
          text: msg || 'Loading',
          background: 'rgba(0, 0, 0, 0.7)',
        });
      } else {
        this.loading.open();
      }
    }
    ,
    closeLoad() {
      if (this.loading) {
        this.loading.close();
        this.loading = null;
      }
    }
    ,
    getRowIdentity(row) {
      return row[this.getIdName()];
    }
    ,
    getIdName() {
      return "idFeedback";
    },
    /**
     * 按钮操作
     */
    btnOperation(type) {
      this.closeLoad();
      switch (type) {
          //新增编辑
        case 1:
          this.ruleForm = {};
          this.dialogTableVisible = !this.dialogTableVisible;
          this.dialogTitle = "新增数据";
          break;
        case 11:
          this.batchDataList = [];
          this.batchDialogTableVisible = !this.batchDialogTableVisible;
          this.batchDialogTitle = "批量新增";
          break;
        case 2:
          this.ruleForm = {};
          if (this.multipleSelection.length < 1) {
            this.warning("至少需要选择一条要编辑的数据");
            return;
          }
          this.dialogTableVisible = !this.dialogTableVisible;
          this.dialogTitle = "编辑数据";
          this.loadById(this.multipleSelection[0][this.getIdName()]);
          // this.$refs.multipleTable.clearSelection();
          break;
          //查看
        case 3:
          if (this.multipleSelection.length != 1) {
            this.warning("查看数据只能选择一条");
            return;
          }
          this.viewVisible = true;
          this.loadById(this.multipleSelection[0][this.getIdName()]);
          break;
          //删除
        case 4:
          this.delete()
          break;
          //刷新
        case 5:
          this.loadByPage(1, this.pageSize);
          break;
          //下载模板
        case 6:
          this.downloadTemplate();
          break;
          //导出
        case 8:
          this.exportAll();
          break;
        default:
          throw error("未知类型");
      }
    }
    ,
    pageClick(type) {
      this.loadByPage(this.currentPage, this.pageSize);
    }
    ,
    pageSizeClick(pageSize) {
      this.pageSize = pageSize;
      this.loadByPage(this.currentPage, pageSize);
    }
    ,
    pageChangeClick(currentPage) {
      this.currentPage = currentPage;
      this.loadByPage(this.currentPage, this.pageSize);
    }
    ,
    editData(row, column, event) {
      this.viewVisible = !this.viewVisible;
      this.loadById(row[this.getIdName()]);
    }
    ,
    //重置数据
    resetForm() {
      this.ruleForm = {};
      this.batchDataList = [];
    }
    ,
    //处理选中的数据
    handleSelectionChange(val) {
      this.multipleSelection = val;
    }
    ,
    /**
     * 初始化数据
     */
    init: function () {
      this.dataList = [];
      this.selectData = [];
      this.loadByPage(this.currentPage, this.pageSize);
      this.loadPermissionResources();
      this.loadSelectData();

    },
    /**
     * 加载资源权限
     */
    loadPermissionResources() {
      let that = this;
      let meta = that.$router.currentRoute.value.meta;
      let data = {"menuId": meta.menuId};
      permissionResources(data).then(res => {
        let redata = res.data.data;
        redata.forEach(item => {
          that.permission[item.resCode] = item.resCode;
        });
      });
    },
    /**
     * 状态码数据
     */
    loadSelectData() {
      let that = this;
      let query = [];
      query.push({
        "propertyName": "statusType",
        "value": "lee_feedback"
      })
      axios.post("/system-config/system/statusinfoEntity/getAllByCondition", query).then(res => {
        let redata = res.data;
        that.selectData = redata.data;
      }).catch(err => {
        error(err);
      });
    }
    ,
    /**
     * 分页显示数据
     */
    loadByPage: function (currentPage, pageSize) {
      let that = this;
      this.load();
      axios.post("/lee-cms/cms/feedbackEntity/pageList", {
        currentPage: currentPage < 1 ? 1 : currentPage,
        pageSize: pageSize || that.pageSize
      }).then(res => {
        let redata = res.data.data;
        that.dataList = redata.dataList;
        that.totalPage = redata.totalPages;
        //that.currentPage = redata.currentPage;
        that.totalData = redata.totalDatas;
      }).catch(err => {
        error(err);
      }).finally(() => {
        that.closeLoad();
      })
    }
    ,
    /**
     * 刷新数据
     */
    refresh: function () {
      this.init();
    }
    ,
    /**
     * 编辑保存数据
     */
    merge: function () {
      let flag = false;
      let that = this;
      that.$refs.ruleForm.validate((valid) => {

        if (!valid) {
          return;
        }
        that.load();
        let statusCode = that.ruleForm.statusCode;
        if (statusCode && that.selectData && that.selectData.length > 0) {
          let sData = that.selectData.find(item => item.statusCode === statusCode);
          that.ruleForm.statusName = sData.statusName;
        }
        axios.post("/lee-cms/cms/feedbackEntity/merge", that.ruleForm).then(res => {
          success(res.data.cnMessage);
          that.closeLoad();
          that.loadByPage(1, that.pageSize);
          that.ruleForm = {};
          that.dialogTableVisible = !that.dialogTableVisible;
        }).catch(err => {
          error(err);
        }).finally(() => {
          that.closeLoad();
        })
      });
    }
    ,
    /**
     * 编辑保存数据
     */
    mergeDraft: function () {
      let that = this;
      this.load();
      let statusCode = that.ruleForm.statusCode;
      if (statusCode && that.selectData && that.selectData.length > 0) {
        let sData = that.selectData.find(item => item.statusCode === statusCode);
        that.ruleForm.statusName = sData.statusName;
      }
      axios.post("/lee-cms/cms/feedbackEntity/mergeDraft", that.ruleForm).then(res => {
        success(res.data.cnMessage);
        that.closeLoad();
        that.loadByPage(1, this.pageSize);
        that.ruleForm = {};
        that.dialogTableVisible = !that.dialogTableVisible;
      }).catch(err => {
        error(err);
      }).finally(() => {
        that.closeLoad();
      })
    }
    ,
    /**
     * 批量编辑保存数据
     */
    batchMerge: function () {
      let that = this;
      this.load();
      axios.post("/lee-cms/cms/feedbackEntity/mergeBatch", that.batchDataList).then(res => {
        success(res.data.cnMessage);
        that.closeLoad();
        that.loadByPage(1, this.pageSize);
        that.batchDataList = [];
        that.batchDialogTableVisible = !that.batchDialogTableVisible;
      }).catch(err => {
        error(err);
      }).finally(() => {
        that.closeLoad();
      })
    }
    ,
    /**
     * 批量编辑保存草稿数据
     */
    batchMergeDraft: function () {
      let that = this;
      this.load();
      axios.post("/lee-cms/cms/feedbackEntity/mergeBatchDraft", that.batchDataList).then(res => {
        success(res.data.cnMessage);
        that.closeLoad();
        that.loadByPage(1, this.pageSize);
        that.batchDataList = [];
        that.batchDialogTableVisible = !that.batchDialogTableVisible;
      }).catch(err => {
        error(err);
      }).finally(() => {
        that.closeLoad();
      })
    }
    ,
    /**
     * 获取已选中数据的Id
     */
    getSelectedData() {
      let ids = [];
      this.multipleSelection.forEach(item => ids.push(item[this.getIdName()]));
      return ids;
    }
    ,
    /**
     * 加载指定数据
     */
    loadById: function (id) {
      let that = this;
      that.load();
      axios.get("/lee-cms/cms/feedbackEntity/getById/" + id).then(res => {
        that.ruleForm = res.data.data;
      }).catch(err => {
        error(err);
      }).finally(() => {
        that.closeLoad();
      })
    }
    ,
    /**
     * 删除数据
     */
    delete: function () {
      let that = this;
      if (this.multipleSelection.length == 0) {
        this.warning("请选择要删除的数据");
        return;
      }
      this.load();
      confirm("确认需要删除选择的数据吗？", function () {
        axios.post("/lee-cms/cms/feedbackEntity/batchDeleteByIdLogic", that.getSelectedData()).then(res => {
          success(res.data.cnMessage);
          that.multipleSelection = [];
          that.closeLoad();
          that.loadByPage(that.currentPage, that.pageSize);
        }).catch(err => {
          error(err)
        }).finally(() => {
          that.closeLoad();
        })
      })

    }
    ,
    /**
     * 上传数据
     */
    upload: function (file, fileList) {

    }
    ,
    /**
     * 上传过程
     */
    uploadProcess: function (event, file, fileList) {
      this.load("数据导入中,请等待");
    }
    ,
    /**
     * 上传失败
     */
    uploadError: function (error, file, fileList) {
      this.closeLoad();
    }
    ,
    /**
     * 上传成功
     */
    uploadSuccess: function (response, file, fileList) {
      this.success(response.cnMessage);
      this.closeLoad();
      this.init();
    }
    ,
    /**
     * 导出所有数据
     */
    exportAll: function () {
      let that = this;
      that.load();
      download("/lee-cms/cms/feedbackEntity/exportData", that.getSelectedData()).catch(err => {
        error(err);
      }).finally(() => {
        that.closeLoad();
      })
    }
    ,
    /**
     * 下载模板
     */
    downloadTemplate: function () {
      let that = this;
      download("/lee-cms/cms/feedbackEntity/downloadTemplate", {}).catch(error => {
        that.error(error);
      });
    }
  },
  created() {
    this.init();
  }
}
</script>